<%-- 
    Document   : registrar_comprador
    Created on : 06-ene-2009, 20:02:06
    Author     : Joel
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<%@ page  import="java.io.*,java.util.*,java.net.*,java.sql.*" %>   
<%@  include file="conexion.jsp" %>   
<!DOCTYPE HTML PUBLIC  "-//W3C//DTD HTML 4.01 Transitional//EN"  "http://www.w3.org/TR/html4/loose.dtd">   
<html>   
<head><title>Ejemplo consulta  JSP</title></head>   
<body><center>   
<%   
Connection  canal = null;   
Statement instruccion=null;   
ResultSet tabla= null;   

//Para Linux
//String conexion = "jdbc:mysql://localhost/bd_marketfarm,root,root";
//Para Windows con ODBC mediante un DSN(Fuente de datos)
String conexion =  "jdbc:odbc:marketfarm";   

//Connection con = DriverManager.getConnection("jdbc:mysql///127.0.0.1:3306/test","root","anirban");


//Abrir el enlace   
try{   
    
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();   
    
    //Class.forName("com.mysql.jdbc.Driver").newInstance();   
    canal =  DriverManager.getConnection(conexion);   
    //canal =  DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/bd_marketfarm","root","root");   
    instruccion =  canal.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);   
}   
catch(ClassNotFoundException e){ out.println(e);}   
catch(SQLException e){ out.println(e);}   
try{   
    tabla =  instruccion.executeQuery("select * from comprador");   
    out.println("<table border=1>");   
    out.println("<tr><th>Codigo</th><th>Nombre</th><th>Direccion</th><th>RUC</th><th>Email</th><th>Telefono</th></tr>");
while(tabla.next()){   
    out.println("<tr><td>"+tabla.getInt(1)+"</td><td>"+tabla.getString(2)+"</td><td>"+tabla.getString(3)+"</td><td>"+tabla.getInt(4)+"</td><td>"+tabla.getString(5)+"</td><td>"+tabla.getInt(6)+"</td><td>"+tabla.getInt(7)+"</td></tr>");   
}   
out.println("</table>");   
}   
catch(Exception e){  out.println(e);}   
%>   
</center></body>   
<html>  
